home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # Script to check forward/reverse name mapping consistency
- # Author: Hans van Staveren <sater@cs.vu.nl>
- #
- PATH=/usr/local/bin:/usr/ucb:/usr/bin
- case $# in
- 0) echo "Usage: $0 [-p] [domain or network] ...";exit;
- esac
- ping=no
- case $1 in
- -p*) ping=yes;shift;;
- esac
- for domain
- do
- case $domain in
- *[A-Za-z]*)
- host -l $domain|sort -u|grep 'has address'|
- grep -v -e '-net[0-9]'|grep -v localhost|
- while read hostname has address ipaddr
- do
- revname=`host $ipaddr 2>/dev/null|sed -n 's/^Name: //p'`
- if [ -z "$revname" ]
- then revname="black-hole"
- fi
- hostname=`echo $hostname|tr '[A-Z]' '[a-z]'`
- revname=`echo $revname|tr '[A-Z]' '[a-z]'`
- if [ $hostname != $revname -a $revname != localhost ]
- then echo "$hostname -> $ipaddr -> $revname"
- fi
- case $ping in
- yes)
- if /usr/etc/ping $hostname 5 >/dev/null 2>&1
- then : nothing
- else
- echo $hostname does not respond
- fi
- ;;
- esac
- done
- ;;
- *)
- # Only class C style networks work currently
- netdom=`echo $domain|sed 's/\(.*\)\.\(.*\)\.\(.*\)/\3.\2.\1/'`.in-addr.arpa
- host -l $netdom|sort -u|grep '^[^0].* PTR '|
- while read enc_ipaddr PTR hostname
- do
- ipaddr=`echo $enc_ipaddr|sed 's/\(.*\)\.\(.*\)\.\(.*\)\.\(.*\)\.IN.*/\4.\3.\2.\1/'`
- if host $hostname 2>/dev/null|grep -s "has address $ipaddr"
- then
- : hunky dory
- else
- echo "$ipaddr -> $hostname, but no A record"
- fi
- case $ping in
- yes)
- if /usr/etc/ping $hostname 5 >/dev/null 2>&1
- then : nothing
- else
- echo $hostname does not respond
- fi
- ;;
- esac
- done
- ;;
- esac
- done
-